# -*- coding:UTF-8 -*-
import shutil
import os

f_txt = open('/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset2/voc_5c/main/val.txt', 'r')
image_train = '/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset2/voc_5c/all/val/images'
label_train = '/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset2/voc_5c/all/val/labels'

context = list(f_txt)
for imagename in context:
    # imagename = imagename[0:6]
    imagename = imagename[:-1]
    
    # imagename3 = imagename
    # print(imagename2,imagename3)

    # imagename = str(imagename)

    imagename1 = imagename+'.jpg'
    # imagepath = '/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset2/voc_5c/images/'+imagename1
    imagepath =os.path.join('/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset2/voc_5c/images',imagename1) 
    
    print('imagepath',imagepath)
    shutil.copy(imagepath,image_train)
    # shutil.copy(imagepath,f_train)
    labelname = imagename + '.txt'
    labelpath = '/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset2/voc_5c/labels/'+labelname
    print('imagepath',labelpath)
    shutil.copy(labelpath,label_train)

    # 删除训练集和验证集，剩余图片为测试集
    # os.remove(imagepath)

#处理Annotations同理只需将.jpg改为.xml